import * as Cesium from "cesium";
import Position from "./position.js";
/**
 * 坐标转换工具
 * Cartesian 笛卡尔空间直角坐标
 * Cartographic 弧度
 * WGS84 gps坐标
 */
class CoordTransform {
    /**
     * WGS84转笛卡尔
     * @param {*} longitude
     * @param {*} latitude
     * @param {*} height
     * @returns
     */
    static WGS84ToCartesian(longitude, latitude, height) {
        let args0 = arguments[0];
        if (args0 instanceof Position) {
            return Cesium.Cartesian3.fromDegrees(args0.longitude, args0.latitude, args0.height, Cesium.Ellipsoid.WGS84);
        }
        if (longitude && latitude) {
            return Cesium.Cartesian3.fromDegrees(longitude, latitude, height || 0, Cesium.Ellipsoid.WGS84);
        }
        return Cesium.Cartesian3.ZERO;
    }
    /**
     * 笛卡尔转WGS84
     * @param {*} cartesian
     * @returns Position
     */
    static cartesianToWGS84(cartesian) {
        if (cartesian) {
            let cartographic = Cesium.Ellipsoid.WGS84.cartesianToCartographic(cartesian);
            return new Position(Cesium.Math.toDegrees(cartographic.longitude), Cesium.Math.toDegrees(cartographic.latitude), cartographic.height);
        }
        return new Position(0, 0);
    }
}

export default CoordTransform;
